<template>
  <van-row type="flex" justify="space-between" align="center">
    <van-col :span="24">
      <van-row type="flex" align="center">
        <van-col :span="4" style="text-align: center;" @click="handleClick">
          <img src="@/assets/images/default_company.png" style="width:45px" alt="">
        </van-col>
        <van-col :span="isOperateMode ? 16 : 19" class="L-margin-left-5" @click="handleClick">
          <div class="L-text L-bold-text">{{item[idobject+'_sname']}}
          </div>
          <div v-if="item.tags"><span v-html="item.tags"></span></div>
        </van-col>
        <van-col v-if="isOperateMode" :span="3" style="display: flex;justify-content: flex-end;">
          <van-checkbox :name="item.account_id"></van-checkbox>
        </van-col>

      </van-row>
    </van-col>
    <!-- <van-col :span="6" style="text-align: right;">
      <van-tag color="#ecf6ff" text-color="#3880ca" size="large" round>{{item.contact_ysdj_enum}}</van-tag>
    </van-col> -->
  </van-row>

  <van-divider />
  <div @click="handleClick">
    <div class="L-secondary-text-color">
      {{ item[idobject+'_saddress']}} 
      <span style="color:#1c71fb;margin-left:5px" @click.stop="handleNavigation(item)">导航</span>
      <!-- <i class="iconfont icon-daohang " style="color:#1c71fb;margin-left:10px;font-size: 16px;" @click.stop="handleNavigation(item)"></i> -->

      
    </div>
    <div class="L-secondary-text-color L-margin-top-5">访问频次:每月{{ item[idobject+'_bfpn']}} 次</div>
    <div v-if="item.account_zjbfsj" class="L-secondary-text-color L-margin-top-5">最近访问时间: {{ item[idobject+'_zjbfsj'] }}</div>
  </div>

  <!-- 地图弹窗 -->
  <van-popup round v-model:show="showeMapPopup" position="bottom" style="width: 100%;height:90%">
    <Map v-if="showeMapPopup" :map-data="currentMapInfo"></Map>
  </van-popup>
</template>

<script setup lang="ts">
import { reactive } from "vue";
import Map from "@/components/base/Map/Map.vue";
import { useCheck } from "@/hooks/hooks.js";
const { checkCustomized } = useCheck();
import { onMounted, ref, defineProps } from "vue";
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const isSelected = ref(false);

const emits = defineEmits(["handleCheck"]);

const props = defineProps({
  item: {
    type: Object,
    default: {},
  },

  idobject: {
    type: String,
    default: "",
  },
  isOperateMode: {
    type: Boolean,
    default: false,
  },
});

function handleClick() {
  const { item, idobject } = props;

  const path = checkCustomized(`/${props.idobject}Card`)
    ? `/${props.idobject}Card`
    : "defaultCard";
  router.push({
    path: path,
    query: {
      itemid: item[`${idobject}_id`],
      idobject,
    },
  });
}
interface mapInfo {
  name: string;
  address: string;
  lat: string | number;
  lng: string | number;
}

const showeMapPopup = ref(false);
const currentMapInfo = reactive<mapInfo>({
  name: "",
  address: "",
  lat: "",
  lng: "",
});

function handleNavigation(item) {
  const { idobject } = props;
  currentMapInfo.name = item[`${idobject}_sname`]
  currentMapInfo.address = item[`${idobject}_saddress`]
  showeMapPopup.value = true;
}

// function handleCheck(item){
//   emits("handleCheck",item,isSelected.value?"check":"cancle")
// }
</script>

<style scoped>
</style>